import http from '../utils/request.js'
import qs from 'qs';

// 获取分类列表API
export function categoryListApi(params) {
    let level = params || 99
    return http({
        url: `/category/category/${level}`,
        method: 'get',
    })
}

// 添加分类API
export function categoryAddApi(data) {
    return http({
        url: `/category/category`,
        method: 'post',
        data: qs.stringify(data)
    })
}

// 删除分类API
export function categoryDeleteApi(cid) {
    return http({
        url: `/category/category/${cid}`,
        method: 'delete',
    })
}

// 修改分类状态API
export function categoryEditStatusApi(cid, value) {
    return http({
        url: `/category/category/${cid}/status/${value}`,
        method: 'put',
    })
}

// 根据id获取分类API
export function categoryByIdApi(cid) {
    return http({
        url: `/category/category/id/${cid}`,
        method: 'get',
    })
}

// 修改分类API
export function categoryEditApi(data) {
    console.log(data);
    return http({
        url: `/category/category/${data.cid}`,
        method: 'put',
        data: qs.stringify(data)
    })
}

